<?php
namespace app\admin\controller;
use think\Db;
use think\Request;
use think\paginator;
use app\admin\model\Recharge as Recharges;

class Recharge extends Common
{
    protected $cModel;
    public function _initialize()
    {
        parent::_initialize();
        $this->cModel = new Recharges;   //别名：避免与控制名冲突
    }

    public function index()
    {

        $dataList = $this->cModel->selectInfo();
        // dump($dataList->toArray());die;
        $this->assign('dataList',$dataList);
        return $this->fetch();
    }

    public function edit($id)
    {
        if(request()->isPost()){

        }else{

            if($id>0){
                $data = $this->cModel->get($id);
            $this->assign('data', $data);
            return $this->fetch();
            }

        }
    }

    public function delete()
    {
        if(request()->isPost()){
            $id = input('id');
            $id_arr = explode(',', $id);
            $where = ['id'=>['in',$id_arr]];
            $result = $this->cModel->where($where)->delete();
            if ($result) {
                return ajaxReturn(lang('action_success'),url('index'));
            } else {
                return ajaxReturn($this->cModel->getError());
            }

        }
    }
}